/* eslint-disable spaced-comment */
/* eslint-disable eqeqeq */
/* eslint-disable comma-dangle */
/* eslint-disable quotes */
/* eslint-disable semi */
import request from "@/utils/request";

// 获取SPU列表数据的接口   /admin/product/{page}/{limit} GET
export const reqSpuList = (page, limit, category3Id) => {
  return request({
    method: "GET",
    url: `/admin/product/${page}/${limit}`,
    params: { category3Id },
  });
};

//   获取SPU信息  /admin/product/getSpuById/{spuId} GET
export const reqSpu = (spuId) => {
  return request({
    method: "GET",
    url: `/admin/product/getSpuById/${spuId}`,
  });
};

//    获取品牌信息       /admin/product/baseTrademark/getTrademarkList GET
export const reqTradeMarkList = () => {
  return request({
    method: "GET",
    url: `/admin/product/baseTrademark/getTrademarkList`,
  });
};

//    获取SPU图片的接口     /admin/product/spuImageList/{spuId} GET
export const reqSpuImageList = (spuId) => {
  return request({
    method: "GET",
    url: `/admin/product/spuImageList/${spuId}`,
  });
};

//   获取平台全部销售属性   /admin/product/baseSaleAttrList GET
export const reqBaseSaleAttrList = () => {
  return request({
    method: "GET",
    url: "/admin/product/baseSaleAttrList",
  });
};

// 修改SPU、添加SPU
export const reqAddOrUpdateSpu = (spuInfo) => {
  if (spuInfo.id) {
    // 修改SPU
    return request({
      method: "POST",
      url: "/admin/product/updateSpuInfo",
      data: spuInfo,
    });
  } else {
    // 添加SPU
    return request({
      method: "POST",
      url: "/admin/product/saveSpuInfo",
      data: spuInfo,
    });
  }
};

//删除SPU /admin/product/deleteSpu/{spuId} DELETE
export const reqDeleteSpu = (spuId) => {
  return request({
    method: "DELETE",
    url: `/admin/product/deleteSpu/${spuId}`,
  });
};

//获取图片  /admin/product/spuImageList/{spuId} GET
/* export const reqSpuImageList = (spuId) => {
  return request({
    method: "GET",
    url: `/admin/product/spuImageList/${spuId}`,
  });
}; */

//获取销售属性 /admin/product/spuSaleAttrList/{spuId} GET
export const reqSpuSaleAttrList = (spuId) => {
  return request({
    method: "GET",
    url: `/admin/product/spuSaleAttrList/${spuId}`,
  });
};

//获取平台属性  /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id} GET
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => {
  return request({
    method: "GET",
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
  });
};

//添加sku /admin/product/saveSkuInfo POST
export const reqAddSku = (skuInfo) => {
  return request({
    method: "POST",
    url: "/admin/product/saveSkuInfo",
    data: skuInfo,
  });
};

//获取SPU列表数据   /admin/product/findBySpuId/{spuId} GET
export const reqSkuList = (spuId) => {
  return request({
    method: "GET",
    url: `/admin/product/findBySpuId/${spuId}`,
  });
};
